#include <stdio.h>
#include <stdlib.h>

#define ROW_COUNT 2
#define COL_COUNT 3
#define B_ROW_COUNT COL_COUNT
#define B_COL_COUNT ROW_COUNT
int main(int argc, char *argv[]) {
  // 二维数组
  int a[ROW_COUNT][COL_COUNT];
  printf("%lu\n", sizeof(a));
  // 二维数组遍历
  // 查看二维数组的地址
  // 获取二维数组元素之和
  int b[][COL_COUNT] = {{3, 5, 8}, {12, 9}, {7, 0, 6, 4}};
  int sum = 0;
  for (int row = 0; row < ROW_COUNT; row++) {
    for (int col = 0; col < COL_COUNT; col++) {
      sum += b[row][col];
    }
  }
  printf("%d\n", sum);
  // 求二维数组的最大值以及对应的行列脚标
  int max = 0;
  int m_row = 0;
  int m_col = 0;
  for (int row = 0; row < ROW_COUNT; row++) {
    for (int col = 0; col < COL_COUNT; col++) {
      if (max < b[row][col]) {
        m_row = row;
        m_col = col;
        max = b[row][col];
      }
    }
  }
  printf("%d %d %d", m_row, m_col, max);
  // 将二维数组的行与列互换
  int c[][COL_COUNT] = {{1, 2, 3}, {4, 5, 6}};
  int d[COL_COUNT][ROW_COUNT];
  for (int i = 0; i < ROW_COUNT; i++) {
    for (int j = 0; j < COL_COUNT; j++) {
      d[j][i] = c[i][j];
    }
  }
  printf("\n");
  for (int i = 0; i < B_ROW_COUNT; i++) {
    for (int j = 0; j < B_COL_COUNT; j++) {
      printf("%d\t", d[i][j]);
    }
    printf("\n");
  }
  return EXIT_SUCCESS;
}
